package test.test01.network.dictionary_UDP;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

import test.test01.network.rollback_UDP.EchoServer;

public class DictServer extends EchoServer{
    private Map<String,String> dictionary = new HashMap<>();

    public DictServer(int port) throws SocketException {
        super(port);

        dictionary.put("cat", "小猫");
        dictionary.put("dog", "小狗");
        dictionary.put("pig", "小猪");
        dictionary.put("mouse", "小老鼠");
        dictionary.put("sheep", "小绵羊");
        dictionary.put("cow", "小母牛");
        dictionary.put("horse", "小马");
        dictionary.put("monkey", "小猴子");
        dictionary.put("chicken", "小公鸡");
        dictionary.put("duck", "小鸭子");
        dictionary.put("goat", "小山羊");
        dictionary.put("lion", "小狮子");
        dictionary.put("tiger", "小老虎");
        dictionary.put("elephant", "小大象");
        dictionary.put("giraffe", "小长颈鹿");
        dictionary.put("zebra", "小斑马");
    }
    @Override
    public String process(String request) {
        String response = dictionary.getOrDefault(request,"没有找到对应的翻译");
        return response;
    }
    public static void main(String[] args) throws IOException {
        DictServer server = new DictServer(9090);
        server.start();
    }
}
